package String;

public class _383_ransomnote {
    //bruce force
    public boolean canConstruct(String ransomNote, String magazine) {
        int mlength = magazine.length();
        int length = ransomNote.length();
        boolean[] used = new boolean[mlength];
        for (int i = 0; i < length; i++) {
            char temp = ransomNote.charAt(i);
            boolean satisfy = false;
            for (int j = 0; j < mlength; j++) {
                if (temp == magazine.charAt(j)) {
                    if (!used[j]) {
                        used[j] = true;
                        satisfy = true;
                        break;
                    }
                }
            }
            if (!satisfy) {
                return false;
            }
        }
        return true;
    }
}
